package com.itheima.algorithm.hashtable;

public class E07Leetcode387 {
    public int firstUniqChar(String s){
        int[] chars=getKey(s);

        for(int i=0;i<s.length();i++){
            char ch=s.charAt(i);
            if(chars[ch-'a']==1){
                return i;
            }
        }
        return 0;
    }

    private static int[] getKey(String s){
        int [] array=new int[26];
        char[] chars=s.toCharArray();
        for(char ch:chars){
            array[ch-'a']++;
        }
        return array;
    }
}
